package com.ghovos.usermangerpgdemo.entity.ext;

import com.ghovos.usermangerpgdemo.entity.RoleEntity;
import com.ghovos.usermangerpgdemo.entity.UserEntity;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author liulingfeng6
 */
@Data
@NoArgsConstructor
public class UserWithRoleIds {
    private Long id;
    private List<Long> roleIds;

    public UserWithRoleIds(UserEntity userEntity){
        this.id = userEntity.getId();
        if(userEntity.getRoleEntities()!=null){
            this. roleIds= userEntity.getRoleEntities().stream().map(RoleEntity::getId).collect(Collectors.toList());
        }
    }
}
